const {User} = require("../../model/user");
module.exports = async (req,res)=>{
  const {username,password,email,role,state} = req.body;
  const id= req.query.id;
  //根据邮箱是否存在
  let user = await User.findOne({_id:id});
  //比对密码
  
  if(user.password == password) {
    console.log('密码相同')
    await User.updateOne({_id:id},{username,email,role,state});
    res.redirect('/admin/user')
    
  } else {
    return res.render('admin/user-edit',{id:id,message:'密码比对失败'})
  }
  
}